package my.test.datastructures.queue;

import java.util.ArrayList;

/**
 * @author LalitR
 */
public class QueueWithALApp {
	public static void main(String[] args) {
		QueueWithAL theQueue = new QueueWithAL();
		theQueue.insert(10); // insert 4 items
		theQueue.insert(20);
		theQueue.insert(30);
		theQueue.insert(40);
		System.out.println("Queue Size: " + theQueue.size());
		System.out.println("Peek: " + theQueue.peekFront());
		theQueue.remove(); // remove 3 items
		theQueue.remove(); // (10, 20, 30)
		theQueue.remove();
		System.out.println("Queue Size: " + theQueue.size());
		System.out.println("Peek: " + theQueue.peekFront());
		theQueue.insert(50); // insert 4 more items
		theQueue.insert(60);
		theQueue.insert(70);
		theQueue.insert(80);
		System.out.println("Queue Size: " + theQueue.size());
		
		while (!theQueue.isEmpty()) // remove and display
		{ // all items
			int n = theQueue.remove(); // (40, 50, 60, 70, 80)
			System.out.print(n);
			System.out.print(" ");
		}
		System.out.println("");
	}
}

class QueueWithAL {
	private ArrayList<Integer> queueList;

	public QueueWithAL()
	{
		queueList = new ArrayList<Integer>(10);
	}

	public void insert(int j)
	{
		queueList.add(j);
	}

	public int remove()
	{
		int temp = queueList.get(0);
		queueList.remove(0);
		return temp;
	}

	public int peekFront()
	{
		return queueList.get(0);
	}

	public boolean isEmpty()
	{
		return queueList.isEmpty();
	}

	public int size()
	{
		return queueList.size();
	}
}